#include<bits/stdc++.h>
#define ll long long
#define L x<<1
#define R x<<1|1
#define mid ((l+r)>>1)
#define lc L,l,mid
#define rc R,mid+1,r
#define Root 1,1,n
#define OK Ll<=l&&r<=Rr
#define rep(x,y,z) for(int x=(y);x<=(z);x++)
#define per(x,y,z) for(int x=(y);x>=(z);x--)
#define repn(x) rep(x,1,n)
#define repm(x) rep(x,1,m)
#define pb push_back
#define e(x) for(int i=h[x],y=to[i];i;i=nxt[i],y=to[i])
#define E(x) for(auto y:p[x])
#define Pi pair<int,int>
#define ui unsigned ll
#define YY puts("Yes"),exit(0)
#define NN puts("No"),exit(0)
#define yy return puts("Yes"),void()
#define nn return puts("No"),void()
inline int read(){int s=0,w=1;char c=getchar();while(c<48||c>57) {if(c=='-') w=-1;c=getchar();}while(c>=48&&c<=57)s=(s<<1)+(s<<3)+c-48,c=getchar();return s*w;}
inline void pf(int x){if(x<0) putchar('-'),x=-x;if(x>9)pf(x/10);putchar(x%10+48);}
using namespace std;
const int N=2e1+5,M=1e6+5,inf=(1LL<<30)-1,mod=998244353;
const ll llf=1e18;
inline void add(int &a,int b){((a+=b)>=mod) and (a-=mod);}
inline int Add(int a,int b){return add(a,b),a;}
inline int mul(int a,int b){return 1LL*a*b%mod;}
inline void Mul(int &a,int b){a=mul(a,b);}
inline void red(int &a,int b){add(a,mod-b);}
inline int Red(int a,int b){return red(a,b),a;}
inline int qp(int a,ll b){if(!b)return 1;int c=qp(a,b>>1LL);Mul(c,c);if(b&1)Mul(c,a);return c;}
inline int INV(int x){return qp(x,mod-2);}
inline bool che(int x,int p){return (x>>p)&1LL;}
int n,a[N];
ll m,b[N];
struct mac{
	int a[18][18];
	mac friend operator*(mac a,mac b){
		mac c;
		memset(c.a,0,sizeof(c.a));
		rep(i,0,n-1)rep(k,0,n-1)if(a.a[i][k])rep(j,0,n-1)add(c.a[i][j],(ll)a.a[i][k]*b.a[k][j]%mod);
		return c;
	}
	mac friend operator+(mac a,mac b){
		mac c;
		memset(c.a,0,sizeof(c.a));
		rep(k,0,n-1)if(a.a[0][k])rep(j,0,n-1)add(c.a[0][j],(ll)a.a[0][k]*b.a[k][j]%mod);
		return c;
	}
}I,pw[65],S,Trans[N],Pw[65],T;
int A[400][400];
inline int id(int x,int y){
	return (x-1)*n+y;
}
inline void Gauss(){
	int m=n*n;
	per(i,m,1){
		rep(j,1,i-1)if(i^j&&A[j][i]){
			int W=mul(INV(A[j][i]),A[i][i]);
			int k=i;
			Mul(A[j][k],W),red(A[j][k],A[i][k]);
			k=m+1;
			Mul(A[j][k],W),red(A[j][k],A[i][k]);
		}
	}
}
inline void init(){
	rep(i,0,n-1)rep(j,i,n-1)pw[0].a[i][j]=a[j+1],I.a[i][i]=1;
	rep(i,1,60)pw[i]=pw[i-1]*pw[i-1];
	int m=n*n;
	repn(i)repn(j){
		repn(k){
			A[id(i,j)][id(k,j)]=pw[0].a[i-1][k-1];
		}
		A[id(i,j)][m+1]=I.a[i-1][j-1];
	}
	Gauss();
	repn(x)repn(y)Pw[0].a[x-1][y-1]=mul(A[id(x,y)][m+1],INV(A[id(x,y)][id(x,y)]));
	T=pw[0]*Pw[0];
	rep(i,1,60)Pw[i]=Pw[i-1]*Pw[i-1];
}
inline void subtaskall(){
	init();
	repn(i){
		Trans[i]=Pw[0];
		ll res=b[i];
		int p=0;
		while(res){
			if(res&1)Trans[i]=Trans[i]*Pw[p];
			res>>=1,p++;
		}
	}
	T=I;
	ll res=m;
	int p=0;
	while(res){
		if(res&1)T=T*pw[p];
		res>>=1,p++;
	}
	int SS=(1<<n)-1,ans=0;
	rep(s,0,SS){
		int ct=0,W=0;
		repn(i)ct+=che(s,i-1);
		ll res=m;
		int St=1;
		repn(i)if(che(s,i-1)){
			res-=b[i]+1,Mul(St,qp(a[i],b[i]+1));
			if(res<0)break;
		}
		if(res<0)continue;
		memset(S.a,0,sizeof(S.a));
		S.a[0][0]=St;
		S=S+T;
		repn(i)if(che(s,i-1))S=S+Trans[i];
		rep(i,0,n-1)add(W,S.a[0][i]);
		if(ct&1)red(ans,W);
		else add(ans,W);
	}
	cout <<ans;
}
inline void Main(){
	cin>>n>>m;
	bool Spe1=1,Spe2=1;
	repn(i)cin>>a[i]>>b[i],Spe1&=b[i]<=300,Spe2&=b[i]>=m;
	return subtaskall();
}
signed main(){
	freopen("yt.in","r",stdin);
	freopen("yt.out","w",stdout);
	int T=1;
	while(T--)Main();
	return 0;
}
